<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sm" uri="/shopizer-tags" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class="container-breadcrumb">
    <div class="row ">
        <div class="col-sm-12">
            <ol class="breadcrumb">
                <li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
                <li class="active"><s:message text="提现审核"/></li>
            </ol>
        </div>
    </div>
    <!--/.row-->
</div>

<div id="container-content" class="container-content">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="col-md-12">用户ID&nbsp;${customerId}</div>
        </div>
        <div class="panel-body">
            <form:form id="myForm" method="POST" cssClass="form-horizontal">
            <div class="form-group">
                <label class="col-sm-2 control-label">当前用户提现金额：</label>

                <div class="col-sm-6">
                    <p class="form-control-static">
                        <c:if test="${operationDetail==1}">集分宝</c:if>
                        <c:if test="${operationDetail==2}">微信</c:if>
                        <c:if test="${operationDetail==3}">话费充值</c:if>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        +${withdrawAccount}元</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"><a href="javaScript:select()">用户完成任务快速查询</a></label>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"><a href="javaScript:query()">用户收徒情况快速查询</a></label>
            </div>

            <c:if test="${remark!=null||checkStatus==2}">
                <div class="form-group">
                    <label class="col-sm-2 control-label">拒绝原因：</label>

                    <div class="col-sm-6">
                        <p class="form-control-static">${remark}</p>
                    </div>
                </div>
            </c:if>

        </div>
        </form:form>
        <div class="panel-footer">
            <c:if test="${checkStatus==1||checkStatus==null}">
                <button id="pass" type="button" data-toggle="modal" data-target="#passCheck" class="btn btn-success" >
                    审核通过
                </button>
                <button id="stop" type="button" data-toggle="modal" data-target="#checkStop" class="btn btn-warning">
                    审核拒绝
                </button>
            </c:if>
            <c:if test="${checkStatus==2}">
                <button id="pass" type="button" data-toggle="modal" data-target="#passCheck" class="btn btn-warning"
                        disabled>审核拒绝
                </button>
            </c:if>
            <c:if test="${checkStatus==3}">
                <button id="pass" type="button" data-toggle="modal" data-target="#passCheck" class="btn btn-success"
                        disabled>审核通过
                </button>
            </c:if>
        </div>
    </div>
</div>

<div class="modal fade" id="checkStop" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">填写拒绝原因</h4>
            </div>
            <div class="modal-body">
                <form id="myform" action="${pageContext.request.contextPath}/checkWithdraw/refuseWithdraw">
                    <div class="form-group">
                        <textarea class="form-control" id="message-text" name="reason"
                                  placeholder="请输入拒绝原因！"></textarea>
                         <span class="help-inline">
                    还可以输入<i class="descChartCount" id="descChartCount"></i>个字符
                </span>
                    </div>
                    <input type="hidden" name="operationType" value="${operationDetail}">
                    <input type="hidden" name="customerId" value="${customerId}">
                    <input type="hidden" name="dateCreat" value="${dateCreate}">
                    <input type="hidden" name="withdrawAccount" value="${withdrawAccount}">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" id="stopCheck" class="btn btn-primary">拒绝</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="passCheck" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     style="padding-top:150px " data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">审核通过</h4>
            </div>
            <div class="modal-body">

                <div id="able">
                    <div class="">确认通过审核吗？</div>
                    <div class="text-center">
                        <button id="available-ok" class="btn btn-warning ">确认</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function query() {
        var customerId = '${customerId}';
        window.location.href = "${pageContext.request.contextPath}/apprentice/getReport?id=" + customerId + "&telphone=&sort=&currentPage=1&pageSize=20";
    }

    function select() {
        var customerId = '${customerId}';
        window.location.href = "${pageContext.request.contextPath}/app/taskInfo?appId=&customerId=" + customerId + "&startTime=&endTime=&_hasFinish=on&currentPage=1&pageSize=20";

    }
    $(document).ready(function () {

        var taskId = '${taskId}';
        var customerId = '${customerId}';
        //===========================================================================================
        $("#appName").val('${appName}');
        $("#appStatus").val('${appStatus}');
        $("#startTime").val('${startTime}');
        $("#endTime").val('${endTime}');

        $("#taskId").val(taskId);
        $("#customerId").val(customerId);

        $("#stopCheck").click(function () {
            $("#stopCheck").attr({"disabled":"disabled"});
            $("#myform").submit();
        });

        $("#available-ok").click(function () {
            $("#available-ok").attr({"disabled":"disabled"});
            var operationType = '${operationDetail}';
            var customerId = '${customerId}';
            var dateCreat = '${dateCreate}';
            var withdrawAccount = '${withdrawAccount}';
            var param = operationType + "," + customerId + "," + dateCreat + "," + withdrawAccount;
            window.location.href = "${pageContext.request.contextPath}/checkWithdraw/passCheckWithdraw?param=" + param;

        });

        $("#message-text").bind("input propertychange", function () {
            var restCount = 500 - getByteLen($("#message-text").val());
            if (restCount <= 0) {
                $("#descChartCount").text("0");
                $(this).val(cutStrForNum($(this).val(), 500));
            } else {
                $("#descChartCount").text(restCount);

            }
        });

        //描述剩余字符数
        $("#descChartCount").text(500 - getByteLen($("#message-text").val()));
    });

    var getByteLen = function (val) {
        var len = 0;
        for (var i = 0; i < val.length; i++) {
            if (val[i].match(/[^x00-xff]/ig) != null) //全角
                len += 2;
            else
                len += 1;
        }
        ;
        return len;
    };

    var cutStrForNum = function (str, num) {
        var len = 0;
        for (var i = 0; i < str.length; i++) {
            if (str[i].match(/[^x00-xff]/ig) != null) //全角
                len += 2;
            else
                len += 1;
            if (len >= num) {
                return str.substring(0, i + 1);
            }
        }
        return str;
    };

</script>